/*
 * MMA8451.c
 *
 *  Created on: Mar 8, 2014
 *      Author: Misael Munoz
 */
#include "Common.h"
#include "MMA8451.h"
#include "i2c_interface.h"
#include "evhdl_iterface.h"

uint8 MMA84x__u8bSomeReg[MMA84x__nReadDataSize] = {0};
uint8 MMA84x_boReadyFlag = 0;

uint8 u8TempVariable = 0;

void MMA84x_HWInit(void)
{
   /*Write fifo mode to 01 in 0x09: F_SETUP FIFO Setup Register*/
   u8TempVariable = 0x47;
   I2C_WriteJob(I2C_enAccelDev, F_SETUP, &u8TempVariable, 0x01);
   do
   {
      EVHD_vStartDispatcher();
   } while (I2C_bDeviceBusy(I2C_enAccelDev) == 1);

   /*Write 0x2A: CTRL_REG1 System Control 1 Register*/
   u8TempVariable = 0x01;
   I2C_WriteJob(I2C_enAccelDev, CTRL_REG1, &u8TempVariable, 0x01);
   do
   {
      EVHD_vStartDispatcher();
   } while (I2C_bDeviceBusy(I2C_enAccelDev) == 1);

   /*Read 0x0B: SYSMOD SystemMode Register*/
   I2C_ReadJob(I2C_enAccelDev, F_SETUP, MMA84x__nReadDataSize, &MMA84x__u8bSomeReg);
   do
   {
      EVHD_vStartDispatcher();
   } while (I2C_bDeviceBusy(I2C_enAccelDev) == 1);

   asm("nop");

}


void MMA84x__vFinishjobHandler(uint8 job)
{
   switch (job)
   {
   case I2C_nTXEvent:
      break;
   case I2C_nRXEvent:
      break;
   default:
      break;
   }
}

